package com.chinatsp.onlineapp.ui.weather;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;

import com.chinatsp.onlineapp.R;
import com.chinatsp.onlineapp.base.BaseActivity;
import com.chinatsp.onlineapp.bean.CityList;
import com.chinatsp.onlineapp.presenter.GetHotCityDao;

public class WeatherSelectActivity extends BaseActivity {

	private Context mContext;
	private GridView gv;
	private List<CityList> list_city;
	private List<Integer> list_selectCity = new ArrayList<Integer>();

	// net
	GetHotCityDao getHotCityDao;
	private Button btn_sure;

	@Override
	public void onRequestSuccess(int requestCode) {
		super.onRequestSuccess(requestCode);
	}

	@Override
	public void onCreate(Bundle args) {
		super.onCreate(args);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_select);
		init();
	}

	private void init() {
		getData();
		initView();

	}

	private void initView() {
		ImageView iv_back = (ImageView) findViewById(R.id.iv_back);
		iv_back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		gv = (GridView) findViewById(R.id.gv);
		btn_sure = (Button) findViewById(R.id.btn_sure);
		list_city = new ArrayList<CityList>();

		list_city.add(new CityList("北京市", "京", true));
		list_city.add(new CityList("天津市", "津", false));
		list_city.add(new CityList("哈尔滨市", "黑", false));
		list_city.add(new CityList("沈阳市", "辽", false));
		list_city.add(new CityList("南京市", "沪", false));
		list_city.add(new CityList("苏州市", "苏", false));
		list_city.add(new CityList("杭州市", "浙", false));
		list_city.add(new CityList("济南市", "鲁", false));
		list_city.add(new CityList("郑州市", "豫", false));
		list_city.add(new CityList("武汉市", "鄂", false));
		list_city.add(new CityList("长沙市", "湘", false));
		list_city.add(new CityList("广州市", "粤", false));
		list_city.add(new CityList("深圳市", "深", false));
		list_city.add(new CityList("重庆市", "渝", false));
		list_city.add(new CityList("成都市", "川", false));
		list_city.add(new CityList("西安市", "陕", false));

		ItemCitySelectAdapter adapter = new ItemCitySelectAdapter(
				WeatherSelectActivity.this, list_city);
		gv.setAdapter(adapter);

		btn_sure.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent intent = new Intent();
				intent.setClass(mContext, WeatherMoreActivity.class);
				startActivity(intent);
				finish();
			}
		});

	}

	private void getData() {
		mContext = this;
		for (int i = 0; i < 5; i++) {

		}

		getHotCityDao = new GetHotCityDao(mContext, this);
		getHotCityDao.getHotList();

	}
}